<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    async function a1() {
      console.log('a1');
      await a2()
      console.log('a3');
    }

    async function a2() {
      console.log('a2');
    }

    console.log('a4');

    setTimeout(() => {
      console.log('a5');
    }, 0)
  
    a1()

    new Promise((resolve, reject) => {
      console.log('a6');
      resolve()
    }).then(() => {
      console.log('a7');
    })

    console.log('a8');
    /* 
    a4=>a1=>a2=>a6=>a8=>a3=>a7=>a5

    
    
     */

  </script>
</body>

</html>
